<?php defined('BASEPATH') OR exit('No direct script access allowed');
/**
 *
 */
class Plugin_Contactsys extends Plugin
{

	function contactus(){
		$form = site_url('home/contactus');
		$captcha = newCaptcha();
		$loader=  loader_image('id="loader_image" class="hidden"'); 
		
		$html = "";
		$html .= "<div id=\"wrap-contactus\">";
		$html .= "<form action=\"{$form}\" id=\"contactus\" name=\"contactus\" method=\"post\" >";
		
		$html .= "<div class=\"wrap-input\">";
		$html .= "<div class=\"text-label\">
					<label>".language_translate('contact_sys_name')."</label>
					<div class=\"help-text\" title=".language_translate('contact_sys_name_hint')."></div>
				</div>";
		$html .= "<div class=\"input-field\"><input type='text' name='name' id='name' maxlength='45' /></div>";
		$html .= "</div>"; 
		
		$html .= "<div class=\"wrap-input\">";
		$html .= "<div class=\"text-label\">
					<label>".language_translate('contact_sys_email')."</label>
					<div class=\"help-text\" title=".language_translate('contact_sys_email_hint')."></div>	
				</div>";
		$html .= "<div class=\"input-field\"><input type='text' name='email' id='email' maxlength='45' /></div>";
		$html .= "</div>"; 
		
		$html .= "<div class=\"wrap-input\">";
		$html .= "<div class=\"text-label\">
					<label>".language_translate('contact_sys_mobile')."</label>
					<div class=\"help-text\" title=".language_translate('contact_sys_mobile_hint')."></div>	
				</div>";
		$html .= "<div class=\"input-field\"><input type='text' name='mobile' id='mobile' maxlength='45' /></div>";
		$html .= "</div>"; 
		
		$html .= "<div class=\"wrap-input\">";
		$html .= "<div class=\"text-label\">
					<label>".language_translate('contact_sys_subject')."</label>
					<div class=\"help-text\" title=".language_translate('contact_sys_subject_hint')."></div>	
				</div>";
		$html .= "<div class=\"input-field\"><input type='text' name='subject' id='subject' maxlength='145' /></div>";
		$html .= "</div>"; 
		
		$html .= "<div class=\"wrap-input\">";
		$html .= "<div class=\"text-label\">
					<label>".language_translate('contact_sys_message')."</label>
					<div class=\"help-text\" title=".language_translate('contact_sys_message_hint')."></div>	
				</div>";
		$html .= "<div class=\"input-field\"><textarea class='message' name='message' id='message' maxlength='550' ></textarea></div>";
		$html .= "</div>"; 
		
		$html .= "<div class=\"wrap-input\">";
		$html .= "<div class=\"text-label\">
					<label>".language_translate('contact_sys_captcha')."</label>
					<div class=\"help-text\" title=".language_translate('contact_sys_captcha_hint')."></div>	
				</div>";
		$html .= "<div class=\"input-field\">
					<div id=\"captcha-section\">{$captcha}</div> 
					<div id=\"captcha-reload\"></div>
					<div class=\"clrboth\"></div>  
					<div style='float:left;clear:left;margin-top:5px;'>
						<input type='text' name='captcha' id='captcha' maxlength='15' />
					</div>
				</div>";
		$html .= "</div>";
		
		$html .= "<div class=\"wrap-input\">";
		$html .= "<div class=\"text-label\"><label></label></div>";
		$html .= "<div class=\"input-field\">
					<input type='submit' class='save-button' name='send' id='send' value='".language_translate('contact_sys_send')."' />
					{$loader}
				</div>";
		$html .= "</div>"; 
		
		$html .= "</form>";
		
		$html .= "<div class=\"wrap-input\">";
		$html .= "<div class=\"text-label\"><label></label></div>";
		$html .= "<div class=\"input-field hidden\" id='errorbox'></div>";
		$html .= "</div>"; 
		
		$html .= "<div class=\"wrap-input\">";
		$html .= "<div class=\"text-label\"><label></label></div>";
		$html .= "<div class=\"input-field hidden\" id='successbox'></div>";
		$html .= "</div>"; 
		
		$html .= "</div>";
		
		$html .= "<script type='text/javascript'>
				$(document).ready(function(){
					var option = { 
							beforeSubmit:  validateBeforeSubmit,  
							success: processAfterSubmit
						};	
					$('#contactus').ajaxForm(option);
					$('.help-text[title]').qtip({ style: { name: 'dark', tip: true } });
				});
				function validateBeforeSubmit(formData, jqForm, options){
					$('#successbox,#errorbox').hide();
					$('#loader_image').toggle();
					return true;
				}
				function processAfterSubmit(responseText, statusText, xhr, form){
					var obj = jQuery.parseJSON( responseText );
					 
					$('#loader_image').toggle();
					if(obj.result == 'ok'){
						$('#successbox').html(obj.msg).show();
						queryurl(BASE_URI+'home/contact_notify');
					}else{
						$('#errorbox').html(obj.msg).show();
					}
				}
			</script>
		";
		
		return $html;
	}




















//endclass
}